package com.huawei.appmarket.service.usercenter.personal.view.card;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask.Status;
import android.view.View;
import android.view.View.OnClickListener;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import java.lang.ref.WeakReference;
import o.cgz;
import o.der;
import o.der.f;
import o.Logger;
import o.doo;
import o.ContentManager;
import o.dug;
import o.ecb;
import o.ecb.e;
import o.ekg;
import o.eko;
import o.ekp;
import o.ekr;
import o.evk;
import o.ll;

public class PersonalCheckOTACard extends PersonalNormalCard implements OnClickListener {
    private boolean ʻ = true;
    private View ʼ;
    private View ॱ;

    class b implements o.ecb.d {
        private WeakReference<View> ˋ;
        final /* synthetic */ PersonalCheckOTACard ˏ;
        private WeakReference<View> ॱ;

        public b(PersonalCheckOTACard personalCheckOTACard, View view, View view2) {
            this.ˏ = personalCheckOTACard;
            this.ॱ = new WeakReference(view);
            this.ˋ = new WeakReference(view2);
        }

        public void ˋ() {
            this.ˏ.ʻ = true;
            if (!(this.ॱ == null || this.ॱ.get() == null)) {
                this.ˏ.ॱ((View) this.ॱ.get(), 0);
            }
            if (this.ˋ != null && this.ˋ.get() != null) {
                this.ˏ.ॱ((View) this.ˋ.get(), 8);
            }
        }
    }

    static class d implements e {
        private d() {
        }

        public void ˏ(ApkUpgradeInfo apkUpgradeInfo) {
            if (apkUpgradeInfo.ˋᐝ() == 1) {
                Intent intent = new Intent();
                intent.setAction("com.huawei.systemmanager.action.CHANGE_HOME_COUNTRY");
                ll ˏ = ll.ˏ(ContentManager.getInstant().getContext());
                if (ˏ != null) {
                    Logger.ˎ("PersonalCheckOTACard", "Cancel OTA,exit HiApp.");
                    ˏ.ˋ(intent);
                }
            }
        }
    }

    public PersonalCheckOTACard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        super.ˏ(view);
        this.ʿ.setText(f.ˊꞌ);
        ˏ(this.ˎ, der.e.ʽॱ);
        view.setOnClickListener(this);
        this.ॱ = view.findViewById(o.der.d.ॱʽ);
        this.ʼ = view.findViewById(o.der.d.ꞌॱ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        boolean ʻ = ekg.ॱ().ʻ();
        if (!ʻ && ekr.ˋ.intValue() == ekr.ˋ(ekp.ˏ)) {
            ekg.ॱ().ˊ(true);
            ʻ = true;
        }
        if (!ʻ) {
            ˎ(false);
        } else if (dug.ॱ(ContentManager.getInstant().getContext().getPackageName()) == null) {
            ˎ(false);
        } else {
            ˎ(true);
        }
    }

    public void onClick(View view) {
        if (this.ʻ) {
            ˊ();
            ˋ();
        }
    }

    protected void ˋ() {
        eko.ˋ(f.ᐧ, KeyAndValue.NUMBER_01);
    }

    protected void ˊ() {
        Context ˋ = ContentManager.getInstant().getContext();
        if (doo.ˊ(ˋ)) {
            ecb ॱ = ecb.ॱ();
            if (ॱ == null || ॱ.getStatus() != Status.RUNNING) {
                ॱ(this.ॱ, 8);
                ॱ(this.ʼ, 0);
                this.ʻ = false;
                ॱ = new ecb((Activity) ˉ().getContext(), new d());
                ecb.ˋ(ॱ);
                ॱ.ˋ(new b(this, this.ॱ, this.ʼ));
                ॱ.execute(new Void[0]);
                return;
            }
            evk.ˏ(ˋ, f.ˉॱ, 0).ˋ();
            return;
        }
        evk.ˏ(ˋ, f.ʻʽ, 0).ˋ();
    }

    private void ॱ(View view, int i) {
        if (view != null) {
            view.setVisibility(i);
        }
    }
}
